// 'use strict';

const HOST = 'https://api.weixin.qq.com/',
	BASE_URL = HOST + 'cgi-bin/',

	WECHAT = {
		//微信公众账号或开放平台APP的唯一标识
		// appId: 'wx0f76558442d392a1',    //公众号
		appId: 'wx099f67bcd3da7623',    //测试号
		//app秘钥
		// appSecret: '59d83f6f53643996aec077f19a7a325b',     //公众号
		appSecret: 'a83a722d2f840981bdb2b856b9a4ce1d',     //测试号
		//验证开发者服务器的token
		token: '18292577207',
		//服务器域名
		serverDomain: 'ef06-180-161-124-64.ngrok.io'
	},

	TEMP = {
		//获取用户授权接口地址前缀
		userOauthApiPrefix: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${WECHAT.appId}&redirect_uri=`,
		//用户授权后的回调地址
		userOauthRedirectUri: `http%3A%2F%2F${WECHAT.serverDomain}%2F`,
		//获取用户授权接口地址后缀
		userOauthApiSuffix: '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect',
		//回调地址-用户信息
		userpage: 'userpage',
		//回调地址-支付
		paypage: 'paypage',
		//回调地址-ECMAScript6
		es6page: 'es6page',
		//回调地址-wifi
		wifipage: 'wifipage'
	},

	WECHAT_PAY = {
		appId: WECHAT.appId,
		appSecret: WECHAT.appSecret,
		//交易过程生成签名的密钥,微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->密钥设置
		apiKey: 'ddddddddddddddddddd',
		//商户申请微信支付后，由微信支付分配的商户收款账号
		mchId: 'ddddddddddddddddddd',
		//统一下单接口地址
		packageApi: 'https://api.mch.weixin.qq.com/pay/unifiedorder',
		//微信付款后的回调地址
		afterPayUrl: ''
	},

	WECHAT_API = {
		//获取用户授权接口地址-用户信息
		userPageOauthApi: TEMP.userOauthApiPrefix + TEMP.userOauthRedirectUri + TEMP.userpage + TEMP.userOauthApiSuffix,
		//获取用户授权接口地址-支付
		payPageOauthApi: TEMP.userOauthApiPrefix + TEMP.userOauthRedirectUri + TEMP.paypage + TEMP.userOauthApiSuffix,
		//获取用户授权接口地址-ECMAScript6
		es6PageOauthApi: TEMP.userOauthApiPrefix + TEMP.userOauthRedirectUri + TEMP.es6page + TEMP.userOauthApiSuffix,
		//获取用户授权接口地址-wifi
		wifiPageOauthApi: TEMP.userOauthApiPrefix + TEMP.userOauthRedirectUri + TEMP.wifipage + TEMP.userOauthApiSuffix,
		//全局普通access_token接口地址(区别第三方页面认证获取的access_token)
		commonAccessTokenApi: `${BASE_URL}token?grant_type=client_credential&appid=${WECHAT.appId}&secret=${WECHAT.appSecret}`,
		//通过code换取网页授权access_token接口地址前缀
		webAuthAccessTokenApiPrefix: `${HOST}sns/oauth2/access_token?appid=${WECHAT.appId}&secret=${WECHAT.appSecret}&code=`,
		//通过code换取网页授权access_token接口地址后缀
		webAuthAccessTokenApiSuffix: '&grant_type=authorization_code',
		//通过网页授权access_token获取用户信息接口地址前缀
		userinfoApiPrefix: `${HOST}sns/userinfo?access_token=`,
		//通过网页授权access_token获取用户信息接口地址后缀
		userinfoApiSuffix: '&lang=zh_CN',
		//构建菜单接口地址前缀
		buildMenusApiPrefix: `${BASE_URL}menu/create?access_token=`
	},

	MENUS = {
		"button": [
			{
				"name": "实时资讯",
				"sub_button": [
					{
						"name": "安束喜大事件",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/hotNews/staggerer`
					},
					{
						"name": "学术前沿",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/hotNews/leading`
					},
					{
						"name": "名师风采",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/hotNews/teacher`
					}
				]
			},
			{
				"name": "特色专栏",
				"sub_button": [
					{
						"name": "微课",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/feature/smallClass`
					},
					{
						"name": "菁英赛区",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/feature/elite`
					},
					{
						"name": "病例库",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/feature/case`
					}
				]
			},
			{
				"name": "学术专区",
				"sub_button": [
					{
						"name": "下肢静脉曲张专区",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/academic/legsVaricosity`
					},
					{
						"name": "静脉畸形专区",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/academic/venousMalformations`
					},
					{
						"name": "内痔专区",
						"type": "view",
						"url": `http://${WECHAT.serverDomain}/index.html#/academic/internalPile`
					},
					{
						"name": "个人中心",
						"type": "view",
						// "url": 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxaa9227d9175f6fae&redirect_uri=http%3A%2F%2Feugcrg.natappfree.cc%2Findex.html%23%2Fuser%2Fcenter&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
						"url": 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxaa9227d9175f6fae&redirect_uri=http%3A%2F%2Fyh9rbh.natappfree.cc%2Findex.html%23%2Fuser%2Fcenter&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
					},
				]
			}
		]
	}
;

// "url": `http://${WECHAT.serverDomain}/index.html#/user/center`s
module.exports = {
	wechat: WECHAT,
	wechatPay: WECHAT_PAY,
	wechatApi: WECHAT_API,
	menus: MENUS
};

